<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>chat</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>
    <script type="text/javascript" charset="utf-8">
        var socket;
        $(document).ready(function () {
            //要写namespace:/channel_A
            socket = io.connect('ws://127.0.0.1:8000/channel_A');
            //测试连接
            socket.on('connect', function () {
                console.log('connect');
            })
            //测试2：发消息+namespace
            // socket.emit('on_response', 'juran', namespace = '/channel_A');
            socket.emit('messages', {msg: 'juran'});
            //测试3：是否会阻塞？不会阻塞，跳过custom_messages，到myEmail
            socket.on('custom_messages', function (data) {
                console.log('***********custom_messages*****')
                console.log(data);
            })
            socket.on('myEmail', function (data) {
                console.log('***********myEmail*****')
                console.log(data)
            })
        })
    </script>
</head>
<body>
<h1>chat</h1>
</body>
</html>